﻿package lobby.exchangeddata
{
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import lobby.events.LobbyEvent;
	import lobby.common.Utility;
	import lobby.constants.ConstData;
	
	/**
	 * ...
	 * @author ...
	 */
	public class LobbyUserInfo extends EventDispatcher
	{
		public var username:String;
		public var password:String;
		public var sessionId:String;
		public var balance:String;
		
		public var maxBet:Number;
		public var minBet:Number;
		public var commissionRate:Number;
		public var memberLtdSeq:String;
		public var oldPass:String;
		public var newPass:String;
		
		public function LobbyUserInfo()
		{
		
		}
		
		public function resultSetSessionToken(result:String):void
		{
			var temp:Array = result.split("@");
			this.sessionId = temp[0];
			trace("this.sessionId:" + this.sessionId);
		}
		
		public function set setSessionId(value:String):void
		{
			this.sessionId = value;
		}
		
		public function get getSessionId():String
		{
			return this.sessionId;
		}
		
		public function init(pUserName:String):void
		{
			this.username = pUserName;
		}
		
		public function resultSetMemberInfo(result:String):void
		{
			trace("resultSetMemberInfo -----------: " + result);
			
			/*	public static const POS_MEMBERBETINFO_CREDIT:int = 21;
			   public static const LEN_MEMBERBETINFO_CREDIT:int = 9;
			
			   public static const POS_MEMBERCOMMISSION_RATIO:int = 9;
			 public static const LEN_MEMBERCOMMISSION_RATIO:int = 10;*/
			
			this.balance = result.substr(ConstData.POS_MEMBERBETINFO_CREDIT, ConstData.LEN_MEMBERBETINFO_CREDIT);
			
			trace("aaa : " + result.substr(ConstData.POS_MEMBERCOMMISSION_RATIO, ConstData.LEN_MEMBERCOMMISSION_RATIO));
			this.commissionRate = Number(result.substr(ConstData.POS_MEMBERCOMMISSION_RATIO, ConstData.LEN_MEMBERCOMMISSION_RATIO));
			
			trace("cuoi : " + this.balance + " : " + this.commissionRate);
			//dispatchEvent(new LobbyEvent(LobbyEvent.UPDATE_BALANCE));				
		}
		
		public function resultSetLimit(result:String):void
		{
			
			trace("userinfo : " + result);
			this.maxBet = Number(result.substr(ConstData.POS_MEMBERLIMIT_UPPER, ConstData.LEN_MEMBERLIMIT_UPPER));
			this.minBet = Number(result.substr(ConstData.POS_MEMBERLIMIT_LOWER, ConstData.LEN_MEMBERLIMIT_LOWER));
		
		/*
		   this.chip = new Array();
		   var totalNumChip:int = parseInt(result.substr(ConstData.POS_NUMCHIP, ConstData.LEN_NUMCHIP));
		   var posChip:int = ConstData.LEN_NUMCHIP + totalNumChip * ConstData.LEN_NUMCHIPAMT;
		   var chipArr:String = result.substr(ConstData.POS_NUMCHIP, posChip);
		   var currentPos = 1;
		   for (var i:int = 1; i <= numChip; i++) {
		   var chipAmount:Number;
		   chipAmount = Number(chipArr.substr(currentPos, ConstData.LEN_NUMCHIPAMT));
		   this.chip.push(chipAmount);
		   currentPos += ConstData.LEN_NUMCHIPAMT;
		   }
		
		   Utility.selectionSort(this.chip, this.chip.length);
		   //trace("resultSetLimit" + this.chip);
		   //Utility.bubbleSort(this.chip, this.chip.length);
		   this.memberLtdSeq = result.substr(ConstData.POS_MEMBER_BETLTDSEQ, ConstData.LEN_MEMBER_BETLTDSEQ);
		 dispatchEvent(new EventData(EventData.UPDATE_USERINFO));	*/
		}
	}

}